﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;


namespace DemoApp1
{
    public partial class Form1 : Form
    {
        [DllImport("Model1.dll", EntryPoint = "predict", CallingConvention = CallingConvention.Cdecl)]
        public static extern void predict(IntPtr model_dir, IntPtr img_dir, float[] pred);
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
           /* String model_dir = "D:/AAAComputerDesign/modelWall.pt";
            String img_dir = "D:\\AAAComputerDesign\\wall_root\\wall_1\\000010.jpg";*/

            IntPtr ptrModeldir = Marshal.StringToHGlobalAnsi("D:/AAAComputerDesign/modelWall.pt");
            IntPtr ptrImgdir = Marshal.StringToHGlobalAnsi("D:\\AAAComputerDesign\\wall_root\\wall_1\\000010.jpg");
            float[] pred = { 0, 0 };
            predict(ptrModeldir, ptrImgdir,pred);
            Int32 pred_value = (Int32)pred[0];
            Int32 pred_class = (Int32)pred[1];
            if (pred_class == 1) richTextBox1.Text =  "经检测该图片中疑似存在翻墙的不文明行为，拍摄时间为11:00，地点为XXX";
            else richTextBox1.Text = "无不文明行为";
        }
    }
}
